<?php

namespace App\depository;

use App\Enum\CommonEnum;
use App\Enum\UsersEnum;
use App\Models\UserHasTeamsModel;

class UserHasTeamsDep
{
    public $model;

    public function __construct()
    {
        $this->model = new UserHasTeamsModel();
    }

    public function firstById($id){
        $res = $this->model->where('id',$id)->first();
        return $res;
    }

    public function add($data)
    {
        $res = $this->model->insert($data);
        return $res;
    }

    public function upd($id, $data)
    {
        $res = $this->model->where('id', $id)->update($data);
        return $res;
    }

    public function delByUserId($userId){
        $res = $this->model->where('user_id',$userId)->delete();
        return $res;
    }

    public function del($id)
    {
        $res = $this->model->where('id', $id)->delete();
        return $res;
    }

    public function getByUserId($userId){
        $res = $this->model->where('user_id',$userId)->get();
        return $res;
    }

    public function firstByTeamIdUserId($teamId,$userId){
        $res = $this->model->where('team_id',$teamId)->where('user_id',$userId)->first();
        return $res;
    }

}
